<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript" src="${staticPath}/js/decimalinput.js"></script>
<script type="text/javascript" src="${staticPath}/js/negotiation.js"></script>

<script type="text/javascript">

$(function(){
	$("#isGuarantee").click(function(){
		if($("#brandName").val() =="0" || $("#brandName").val() == null){
			top.$.jBox.tip('请先选择品牌', 'warning');
			$("#brandName").focus();
		}
	});
	var brandIds = '${brandsId}';
	var obj = document.getElementById("brandName");
	obj.options.add(new Option("---请选择---", "0"));
	for(var i=0; i<assBrandList.length; i++){
		var brandCname = $("#brandCname"+assBrandList[i]).val();
		var brandId = $("#brandId"+assBrandList[i]).val();
		if(brandIds == brandId){
			var option=new Option(brandCname, brandId);
			option.selected=true;
			obj.options.add(option);
		}else{
			obj.options.add(new Option(brandCname, brandId));
		}
	}
	$("#lower").decimalinput();
	$("#upper").decimalinput();
	$("#deductRate").decimalinput();
	$("#guaranteeAmount").decimalinput();
	$("#amount").decimalinput();
	$("#deductRate").decimalinput(3);
});

function chenageDeductCode(t,value){
	if(value ==="0" ||value ===""){
		$("#guaranteeType").attr("disabled","disabled");
		$("#guaranteeType").val("");
		$("#iscommGuarantee").attr("disabled","disabled");
		$("#iscommGuarantee").val("");
		$("#guaranteeAmount").attr("disabled","disabled");
		$("#guaranteeAmount").val("");
		$("#countbase_base").attr("disabled","disabled");
		$("#countbase_base").val("");
		$("#iscommGuarantee").children("option").each(function(){
			if($(this).val() == ""){
				$(this).attr("selected","selected");
			}
		});
		$("#countbase_base").children("option").each(function(){
			if($(this).val() == ""){
				$(this).attr("selected","selected");
			}
		});
	}else if(value ==="1"){
		$("#guaranteeType").removeAttr("disabled");
		$("#iscommGuarantee").removeAttr("disabled");
		$("#guaranteeAmount").removeAttr("disabled");
		$("#countbase_base").removeAttr("disabled");
		if('${base.iscommGuarantee}'==null||'${base.iscommGuarantee}'==""){
			$("#iscommGuarantee").children("option").each(function(){
				
				if($(this).val() == "0"){
					$(this).attr("selected","selected");
				}
			});
		}
		if('${base.countBase}'==null||'${base.countBase}'==""){
			$("#countbase_base").children("option").each(function(){
				if($(this).val() == "0"){
					$(this).attr("selected","selected");
				}
			});
		}
	}
}

</script>
<div class="modal-dialog">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">&times;</button>
			<h4 class="modal-title">添加销售分成及结算条款信息</h4>
		</div>
		<!-- /modal-header -->
		<form action="${contextPath}/biz/contract/assrecord/createAssbaseitems" method="post" id="paramForm">
			<div class="modal-body">
				<table class="table">
					<tr>
						<td>
							<div class="col-sm-12">
								<label for="validType_lab" class="col-sm-5 control-label">品牌:</label>
								<div class=" input-group col-sm-7">
									<select id="brandName" class="form-control required" >	
									</select>
									<input type="hidden" id="barndId_base"  value="">
									<input type="hidden"  id="operate_base" value=""/>
									<input type="hidden"  id="base_seq" value=""/>
								</div>
							</div>
						</td>
						<td>
							<div class="col-sm-12">
								<label for="isGuarantee_lab" class="col-sm-5 control-label">是否保底:</label>
								<div class="col-sm-7">
									<ossp:select dictType="DEFEND_BASE" id="isGuarantee" defaultSelected="${baseitems.isGuarantee }"
										name="isGuarantee" class_="form-control required" onchange="chenageDeductCode(this,this.options[this.options.selectedIndex].value)"  ></ossp:select>
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td>	
							<div class="col-sm-12">
								<label for="guaranteeType_lab" class="col-sm-5 control-label">保底形式:</label>
								<div class="col-sm-7">
									<ossp:select dictType="GUARANTEE_TYPE" id="guaranteeType" defaultSelected="${baseitems.guaranteeType }"
										name="guaranteeType" class_="form-control required" disabled="disabled"></ossp:select>
								</div>
							</div>
						</td>	
						<td>
							<div class="col-sm-12">
								<label for="updateBy" class="col-sm-5 control-label">
										<c:if test="${contractType != 'Z200' }">保底金额:</c:if>
										<c:if test="${contractType == 'Z200'}">保底租金:</c:if>
								</label>
								<div class=" col-sm-7">
									<input type="text" class="form-control required" disabled="disabled"
										id="guaranteeAmount" name="guaranteeAmount" value="${baseitems.guaranteeAmount }"  />
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td>
	  	 					<div class="col-sm-12">
							    <label for="codeType_lab" class="col-sm-5 control-label">销售码类型:</label>
								<div class=" col-sm-7">
								
										<ossp:select  defaultSelected="${base.codeType}" class_="form-control" id="codeType"  dictType="CONTRACT_CODE_TYPE"></ossp:select>
								</div>
							</div>
						</td>
						<td>
	  	 					<div class="col-sm-12">
							    <label for="deductType_lab" class="col-sm-5 control-label">扣款方式:</label>
								<div class="  col-sm-7">
										<ossp:select defaultSelected="${base.deductType}" dictType="PAYMENT_TYPE" id="deductType_base" class_="form-control"></ossp:select>
								</div>
						  	</div>
						</td>
					</tr>
					<tr>
						<td>
							<div class="col-sm-12">
								<label for="lower_lab" class="col-sm-5 control-label">扣款下限:</label>
								<div class="input-group col-sm-7">
									<input type="text" class="form-control required" id="lower" name="lower" value="${baseitems.lower }" />
								</div>
							</div>
						</td>
						<td>
							<div class="col-sm-12">
								<label for="upper_lab" class="col-sm-5 control-label">扣款上限:</label>
								<div class=" input-group col-sm-7">
									<input type="text" class="form-control required" id="upper" name="upper" value="${baseitems.upper }" />
								</div> 
							</div>
						</td>
					</tr>
					<tr>
						
						<td>
							<div class="col-sm-12">
								<label for="validType_lab" class="col-sm-5 control-label">时效类型:</label>
								<div class=" input-group col-sm-7">
									<ossp:select dictType="DEFEND_SYTLE" id="validType" name="validType" defaultSelected="${baseitems.validType }" class_="form-control required"></ossp:select>
								</div>
							</div>
						</td>
						<td>
							<div class="col-sm-12">
								<label for="deductRate_lab" class="col-sm-5 control-label">扣率:</label>
								<div class=" input-group col-sm-7">
									<input type="text" class="form-control required"
										id="deductRate" name="deductRate" value="${baseitems.deductRate }" />
								</div>
							</div>
						</td>
					</tr>
					 <tr>
						<td  >
	  	 					<div class="col-sm-12">
								    <label for="iscommGuarantee_lab" class="col-sm-5 control-label">通用保底:</label>
									<div class="  col-sm-7">
										<ossp:select style=" hidden"  id="iscommGuarantee" disabled="disabled" dictType="ISCOMM_GUARANTEE" class_="form-control" defaultSelected="${base.iscommGuarantee}"></ossp:select>		
									</div>
							 </div>
						</td>
						<td>
	  	 				   <div class="col-sm-12">
								    <label for="countbase_base_lab" class="col-sm-5 control-label">促销是否计入保底:</label>
									<div class="  col-sm-7">
										<ossp:select  id="countbase_base" disabled="disabled" dictType="COUNTBASE_BASE" class_="form-control" defaultSelected="${base.countBase}"></ossp:select>
									</div>
							 </div>
						</td>
				 	</tr>
				 	<c:if test="${contractType == 'Z200' }">
					 	<tr>
					 		<td   >
		  	 					<div class="col-sm-12">
									    <label for="isCompare_lab" class="col-sm-5 control-label">是否比高:</label>
										<div class="  col-sm-7">
												<ossp:select id="isCompare_base" defaultSelected="${base.isCompare}" class_="form-control" dictType="COMPARE_HIGH"></ossp:select>
										</div>
								  	</div>
							</td>
							<td>
		  	 						<div class="col-sm-12">
									<label for="taxRate_lab" class="col-sm-5 control-label">租金支付日:</label>
									<div class=" col-sm-7">
											 <ossp:select  id="payDate"  dictType="PAY_DATE" class_="form-control" defaultSelected="${base.payDate}"></ossp:select>
									</div>
								</div>
							</td>
					 	</tr>
					 	
					 	 	 	
				 	</c:if> 	 		
					<tr>
	            		<td  >
	  	 					<div class="col-sm-12">
								    <label for="tstartDate_lab" class="col-sm-5 control-label">开始日期:</label>
									<div class="  col-sm-7">
								 		<div class="input-group date startDate " data-date="" data-date-format="yyyy-mm-dd" >
									          <input class="form-control" value="<fmt:formatDate value="${base.startDate}" type="both" pattern="yyyy-MM-dd"/>" id="startDate_base" name="startDate_base" disabled="disabled"    size="10"  data-rule="required" type="text" />
						                   	 <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
					                	</div>
									</div>
							  	</div>
						</td>
						
						<td  >
	  	 					<div class="col-sm-12">
								    <label for="endDate_lab" class="col-sm-5 control-label">结束日期:</label>
									<div class="  col-sm-7">
										<div class="input-group date endDate " data-date="" data-date-format="yyyy-mm-dd" >
										          <input class="form-control" id="endDate_base" name="endDate_base" disabled="disabled"   value="<fmt:formatDate value="${base.endDate}" type="both" pattern="yyyy-MM-dd"/>"    size="10"  data-rule="required" type="text" />
							                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
						                	</div>
									</div>
							  	</div>
						</td>
				 </tr>
				</table>
				<div class="form-group">
					<label class="col-sm-2 control-label">备注:</label>
					<div class="col-sm-10">
						<textarea class="form-control required" rows="3" id="remarks" name="remarks">${baseitems.remarks }</textarea>
					</div>
				</div>
			</div>
			<div
			 class="modal-footer">
			 	<input type="hidden" id="updateBaseitemsId" />
			 	<c:if test="${flag != 'view' }">
					<button type="button" class="btn btn-primary" onclick="addRow()" id="baseitems_ok">确定</button>
				</c:if>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</form>
	</div>
</div>
 <script type="text/javascript">
	var start=0;
	var end=0;
	$('.startDate').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0,
		setLocalDate: new Date(2011, 2, 5),
		format: 'yyyy-mm-dd'
    }).on('changeDate',function(ev){
    	start = ev.date.valueOf();
    	
   });

	$('.endDate').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0,
		format: 'yyyy-mm-dd'	
    }).on('changeDate',function(ev){
    	  end = ev.date.valueOf();
    	
   });
</script>
</body>